package moxl.parser.assemblers.comment;

import moxl.parser.ParserException;
import moxl.parser.assemblers.AbstractTokenFedMarkupAssembler;
import moxl.parser.assemblers.AssemblerException;
import moxl.tokenizer.TokenStream;
import moxl.tokenizer.TokenizerException;
import moxl.tokenizer.xml.XmlTokenType;

public class CommentAssembler extends AbstractTokenFedMarkupAssembler<CommentAssemblerState, CommentAssemblerContext>
{
	@Override
	protected CommentAssemblerContext createAssemblerContext(TokenStream tstream)
	{
		return new CommentAssemblerContext(tstream);
	}

	@Override
	protected void handleInput(XmlTokenType type, CommentAssemblerContext ctx) throws ParserException, TokenizerException
	{
		CommentStateDelegateBase delegate = ctx.getState().getDelegate();

		switch (type)
		{
		case OPEN_COMMENT:
			delegate.acceptOpenComment(ctx);
			break;

		case CLOSE_COMMENT:
			delegate.acceptCloseComment(ctx);
			break;

		case COMMENT_BODY:
			delegate.acceptCommentBody(ctx);
			break;

		case DOUBLE_HYPHEN:
			delegate.acceptDoubleHyphen(ctx);
			break;

		default:
			throw new AssemblerException("Parser cannot handle token: " + ctx.getToken(), ctx.getLocation());
		}
	}

}
